package com.youhong.teethcare.plaque.dialogs;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioGroup;

import com.youhong.teethcare.R;
import com.youhong.teethcare.customviews.MyRadioGroup;

/**
 * Created by Administrator on 2018/9/12.
 */

public class BleedingChooseDialog extends Dialog {

    public void setCallback(BleedingOnClickCallback callback) {
        this.callback = callback;
    }

    BleedingOnClickCallback callback;
    MyRadioGroup rg;
    Button btn_ok;
    ImageView iv_close;

    public BleedingChooseDialog(@NonNull Context context) {
        super(context);
        setContentView(R.layout.dialog_bleedingchoose);
        getViews();
    }

    public BleedingChooseDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        setContentView(R.layout.dialog_bleedingchoose);
        getViews();
    }

    private void getViews() {
        btn_ok = findViewById(R.id.plaqueChoose_btn_ok);
        btn_ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (callback != null) {

                    int type = 0;
                    switch (rg.getCheckedRadioButtonId()) {
                        case R.id.plaqueChoose_rb_healthy:
                            type = 0;
                            break;
                        case R.id.plaqueChoose_rb_bleeding:
                            type = 2;
                            break;
                        case R.id.plaqueChoose_rb_abscess:
                            type = 3;
                            break;
                        case R.id.plaqueChoose_rb_bleedingPlusAbscess:
                            type = 4;
                            break;
                    }
                    callback.onCallback(type);
                }
                BleedingChooseDialog.this.dismiss();
            }
        });
        rg = findViewById(R.id.plaqueChoose_rg);
        rg.check(R.id.bleedingChoose_rb_healthy);
        iv_close = findViewById(R.id.dialog_iv_close);
        iv_close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                BleedingChooseDialog.this.dismiss();

            }
        });
    }

    public interface BleedingOnClickCallback {
        void onCallback(int type);
    }

}
